<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>校园信息门户系统</title>
    <link rel="stylesheet" href="https://www.layuicdn.com/layui/css/layui.css">
    <link rel="stylesheet" href="../static/css/index.css">
</head>
<body>

<div class="layui-layout layui-layout-admin">
    <div class="layui-header">
        <div class="layui-logo layui-hide-xs layui-bg-black">校园信息门户系统</div>
        <ul class="layui-nav layui-layout-right">
            <li class="layui-nav-item layui-hide layui-show-md-inline-block">
                <a href="javascript:;">
                    <img src="//tva1.sinaimg.cn/crop.0.0.118.118.180/5db11ff4gw1e77d3nqrv8j203b03cweg.jpg"
                         class="layui-nav-img">
                    <c:if test="${sessionScope.admin_user!=null}">
                        ${sessionScope.admin_user.adminName}
                    </c:if>
                    <c:if test="${sessionScope.teacher_user!=null}">
                        ${sessionScope.teacher_user.teacherName}
                    </c:if>
                    <c:if test="${sessionScope.student_user!=null}">
                        ${sessionScope.student_user.studentName}
                    </c:if>
                </a>
            </li>
            <li class="layui-nav-item" lay-header-event="menuRight" lay-unselect>
                <a href="javascript:;">
                    <i class="layui-icon layui-icon-more-vertical"></i>
                </a>
            </li>
        </ul>
    </div>

    <div class="layui-side layui-bg-black">
        <div class="layui-side-scroll">
            <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
            <ul class="layui-nav layui-nav-tree" lay-filter="my-nav">
                <li class="layui-nav-item layui-nav-itemed">
                    <a class="" href="javascript:;">学生管理</a>
                    <dl class="layui-nav-child">
                        <c:if test="${sessionScope.student_user!=null}">
                            <dd><a href="javascript:;" class="my-menu" my-layui-id="1" my-layui-href="/studyRoom/applyRoom">自习室申请</a></dd>
                        </c:if>
                        <dd><a href="javascript:;" class="my-menu" my-layui-id="2" my-layui-href="/studyRoom/roomStatus">自习室查询</a></dd>
                        <c:if test="${sessionScope.admin_user==null}">
                            <dd><a href="javascript:;" class="my-menu" my-layui-id="3" my-layui-href="/teacher/evaluation">教师评价</a></dd>
                        </c:if>
                        <c:if test="${sessionScope.admin_user!=null}">
                            <dd><a href="javascript:;" class="my-menu" my-layui-id="4" my-layui-href="/studyRoom/roomAudit">自习室申请审核</a></dd>
                            <dd><a href="javascript:;" class="my-menu" my-layui-id="5" my-layui-href="/teacher/teacherEval">教师评价管理</a></dd>
                        </c:if>
                    </dl>
                </li>
                <c:if test="${sessionScope.admin_user==null}">
                    <li class="layui-nav-item">
                        <a href="javascript:;">活动管理</a>
                        <dl class="layui-nav-child">
                            <c:if test="${sessionScope.student_user!=null}">
                                <dd><a href="javascript:;" class="my-menu" my-layui-id="6" my-layui-href="/activity/activityApply">活动申请</a></dd>
                            </c:if>
                            <c:if test="${sessionScope.teacher_user!=null}">
                                <dd><a href="javascript:;" class="my-menu" my-layui-id="7" my-layui-href="/activity/auditActivity">活动申请审核</a></dd>
                            </c:if>
                        </dl>
                    </li>
                </c:if>
            </ul>
        </div>
    </div>

    <div class="layui-body">
        <!-- 内容主体区域 -->
        <div class="layui-tab" lay-allowClose="true" lay-filter="tab-filter">
            <ul class="layui-tab-title">

            </ul>
            <div class="layui-tab-content">
            </div>
        </div>
    </div>

<%--    <div class="layui-footer">--%>
<%--        <!-- 底部固定区域 -->--%>
<%--        底部固定区域--%>
<%--    </div>--%>
</div>

<script src="https://www.layuicdn.com/layui/layui.js"></script>
<script>
    //JS
    layui.use(['element', 'layer', 'util'], function () {
        var element = layui.element,
            layer = layui.layer,
            util = layui.util,
            $ = layui.$;

        $(function () {
            $('.my-menu').click(function () {
                let data = $(this);
                let my_layui_id = data.attr('my-layui-id');
                let href = data.attr('my-layui-href');
                let title = data.text()

                // 需要去循环遍历查看我们点击的选项卡是否已经生成出来了
                let list = $(".layui-tab-title li");
                let flag = false;//false 表示为生成,true,表示已经存在
                for (let i = 0; i < list.length; i++) {
                    if ($(list[i]).attr('lay-id') === my_layui_id) {
                        // 说明已经存在点击的选项卡,无需再次添加
                        flag = true;
                        break;
                    }
                }
                if (!flag) {
                    // 如果不存在点击的选项卡,那么就添加一个选项卡
                    element.tabAdd('tab-filter', {
                        title: title,
                        content: '<iframe  style="min-height:70vh;width: 100%" frameborder="no"  scrolling="auto" src='+href+'></iframe>', //支持传入html,
                        id: my_layui_id
                    })
                }
                // 最后再切换到,点击的选项卡
                element.tabChange('tab-filter', my_layui_id);
            })
        })
    });
</script>
</body>
</html>